package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.ClientCarDao;
import com.x.erp.model.Car;
import com.x.erp.model.ClientSelectTemplate;
import com.x.erp.rpc.ClientCarRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Service(interfaceName = "com.x.erp.rpc.ClientCarRpcService", timeout = 60000)
public class ClientCarService extends BaseService implements ClientCarRpcService {

	@Autowired
	private ClientCarDao clientCarDao; // C端车辆信息服务

	/**
	 * 查询客户端订阅车辆列表信息
	 * @param clientSelectTemplate
	 * @return
	 */
	@Override
	public List<Car> selectCarListBySelectTemplate(Car car, ClientSelectTemplate clientSelectTemplate){
		try {
			return clientCarDao.selectCarListBySelectTemplate(car, clientSelectTemplate);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询车辆列表信息
	 * @param car
	 * @return
	 */
	@Override
	public List<Car> selectCarList(Car car){
		try {
			return clientCarDao.selectCarList(car);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}
}
